package com.example.rbacmanage.service.impl;

import com.example.rbacmanage.entity.SysJobLog;
import com.example.rbacmanage.exception.MyException;
import com.example.rbacmanage.mapper.SysJobLogMapper;
import com.example.rbacmanage.service.SysJobLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysJobLogServiceImpl implements SysJobLogService {
    @Autowired
    private SysJobLogMapper sysJobLogMapper;
    @Override
    public void save(SysJobLog sysJobLog) {
        sysJobLog.setCreateTime(new Date());
        sysJobLogMapper.insert(sysJobLog);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            sysJobLogMapper.del(id);
        }
    }

    @Override
    public void update(SysJobLog sysJobLog) {
        sysJobLogMapper.update(sysJobLog);
    }

    @Override
    public List<SysJobLog> getAll(SysJobLog sysJobLog) {
        return sysJobLogMapper.list(sysJobLog);
    }

    @Override
    public PageInfo<SysJobLog> getPage(SysJobLog sysJobLog) {
        PageHelper.startPage(sysJobLog.getPage(),sysJobLog.getLimit());
        return new PageInfo<>(getAll(sysJobLog));
    }

    @Override
    public SysJobLog getById(Long id) {
        return sysJobLogMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(SysJobLog sysJobLog) {
        return sysJobLogMapper.count(sysJobLog);
    }

    @Override
    public void checkRepeat(SysJobLog sysJobLog) throws MyException {

    }

    @Override
    public void cleanJobLog() {
        sysJobLogMapper.cleanJobLog();
    }
}
